home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-08-03 | 1.7 KB | 76 lines | [TEXT/CWIE] |
- #include "BSDOffscreenLib.h"
- #include "BSDMenubarLib.h"
-
- WindowPtr window;
- GWorldPtr srcPort, maskPort, offscreen, backPort;
- Rect bounds, d, p, u;
- short horz = 2, vert = 2;
-
- void Init (short num) {
- MaxApplZone();
-
- for (short x = 1; x <= num; x++) MoreMasters();
-
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
-
- FlushEvents(everyEvent, 0);
- }
-
- void InitPorts (void) {
- SetRect(&bounds, 0, 0, 144, 144);
-
- window = NewCWindow(nil, &qd.screenBits.bounds, "\p", false, plainDBox, (WindowPtr)-1L, false, 0);
- srcPort = CreateGWorldPict(16, bounds, GetPicture(128));
- maskPort = CreateGWorldPict(1, bounds, GetPicture(129));
- offscreen = CreateGWorldEmpty(16, window->portRect);
- backPort = CreateGWorldEmpty(16, window->portRect);
- Screen2GWorld(backPort, srcCopy + ditherCopy);
-
- ShowWindow(window);
- }
-
- void DisposePorts (void) {
- DisposeWindow(window);
- DisposeGWorld(srcPort);
- DisposeGWorld(maskPort);
- DisposeGWorld(offscreen);
- }
-
- void main (void) {
- Init(3);
- InitPorts();
- HideMenuBar();
- HideCursor();
-
- GWorld2GWorld(backPort, offscreen, srcCopy);
- GWorld2Window(offscreen, window, srcCopy);
-
- d = bounds;
-
- while (!Button()) {
- p = d;
-
- OffsetRect(&d, horz, vert);
-
- if (d.left <= -1) horz = -horz;
- if (d.top <= -1) vert = -vert;
- if (d.right >= (window->portRect.right + 1)) horz = -horz;
- if (d.bottom >= (window->portRect.bottom + 1)) vert = -vert;
-
- UnionRect(&p, &d, &u);
-
- GWorld2GWorldRect(backPort, offscreen, u, u, srcCopy);
- GWorld2GWorldMask(srcPort, maskPort, offscreen, bounds, d);
- GWorld2WindowRect(offscreen, window, u, u, srcCopy);
- }
-
- DisposePorts();
- ShowMenuBar();
- ShowCursor();
- }